'use strict';
var d = Object.defineProperty;
var l = (t, r, e) =>
  r in t
    ? d(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e })
    : (t[r] = e);
var a = (t, r, e) => (l(t, typeof r != 'symbol' ? r + '' : r, e), e);
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const s = require('../doc/createNode.cjs'),
  c = require('../stringify/stringifyPair.cjs'),
  P = require('./addPairToJSMap.cjs'),
  o = require('./identity.cjs');
function y(t, r, e) {
  const i = s.createNode(t, void 0, e),
    u = s.createNode(r, void 0, e);
  return new n(i, u);
}
class n {
  constructor(r, e = null) {
    a(this, 'key');
    a(this, 'value');
    Object.defineProperty(this, o.NODE_TYPE, { value: o.PAIR }),
      (this.key = r),
      (this.value = e);
  }
  clone(r) {
    let { key: e, value: i } = this;
    return (
      o.isNode(e) && (e = e.clone(r)),
      o.isNode(i) && (i = i.clone(r)),
      new n(e, i)
    );
  }
  toJSON(r, e) {
    const i = e != null && e.mapAsMap ? new Map() : {};
    return P.addPairToJSMap(e, i, this);
  }
  toString(r, e, i) {
    return r != null && r.doc
      ? c.stringifyPair(this, r, e, i)
      : JSON.stringify(this);
  }
}
exports.Pair = n;
exports.createPair = y;
